package com.fr.report.script.function;

import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;
import com.fr.report.script.core.FunctionHelper;

public class TANH extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length < 1)
      return Primitive.ERROR_NAME;
    Object localObject = paramArrayOfObject[0];
    if (localObject instanceof Number)
    {
      double d = ((Number)localObject).doubleValue();
      return FunctionHelper.parsePrimitiveDouble((Math.pow(2.718281828459045D, d) - Math.pow(2.718281828459045D, -d)) / (Math.pow(2.718281828459045D, -d) + Math.pow(2.718281828459045D, d)));
    }
    return Primitive.ERROR_NAME;
  }

  public Function.Type getType()
  {
    return Function.MATH;
  }

  public String getCN()
  {
    return "TANH(number):返回某一数字的双曲正切值。\nnumber:为任意实数。\n双曲正切的计算公式如下：\n示例:\nTANH(-2) 等于 -0.96403\nTANH(0) 等于 0\nTANH(0.5) 等于 0.462117\n";
  }

  public String getEN()
  {
    return "TANH(number): Returns the hyperbolic tangent of a number.\nnumber is any real number\n\nExample:\n   TANH(-2) = -0.96403\n   TANH(0) = 0\n   TANH(0.5) = 0.462117\n";
  }
}